package com.blb.aop.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author lvtian
 * @date 2022/12/26 10:21
 */
@Aspect
@Component
public class LogAdvise {
    @Pointcut("execution(* com.blb.aop.service.*ServiceImpl.*(..))")
    public void pointcut(){}

    @Before("pointcut()")
    public void beforeLog(){
        System.out.println("前置通知");
    }
    @After("pointcut()")
    public void afterLog(){
        System.out.println("后置通知");
    }
    @AfterReturning("pointcut()")
    public void afterReturningLog(){
        System.out.println("最终通知");
    }
    @AfterThrowing("pointcut()")
    public void afterThrowingLog(){
        System.out.println("异常通知");
    }
    @Around("pointcut()")
    public void aroundLog(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕前置通知");
        Object result = joinPoint.proceed();
        System.out.println("执行方法 返回值"+result);
        System.out.println("环绕后置通知");
    }
}
